<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>SmartTel设备接口DEMO</title>
  <script src="./js/jquery.min.js"></script>
  <script src="./js/jquery.md5.js"></script>
  <script src="./js/voip.js"></script>
  <style type="text/css">
  	body{font-family: '微软雅黑'; font-size: 12px; padding-top: 10px; }
  	.clear{font-size: 0px; line-height: 0px; height: 0px; float: none; clear: both; }
  	input[type=text]{line-height: 23px; height: 23px; border: 1px solid #CCC; border-radius: 3px; padding: 0px 7px; }
  	label{line-height: 23px; padding-left: 35px; }
  	fieldset{margin: 0px; padding: 10px 0px 20px 0px; border: 1px solid #ccc; border-radius: 3px; }
  	legend{margin-left: 25px; }
  	form{float: left; width: 400px; margin: 20px 0px 0px 30px; }
  	iframe{float: left; width: 400px; margin: 0px 0px 0px 30px; border: none; }
  	textarea{border: 1px solid #ccc; border-radius: 3px; margin: 0px 0px 10px 50px; width: 290px; height: 200px; }
  	a{display: block; width: 42px; height: 23px; border: 1px solid #ccc; line-height: 23px; text-align: center; border-radius: 3px; margin: 0px auto; cursor: pointer; }
  	a:hover{background-color: #FAFAFA; }
  	.hr{border: none; display: block; height: 12px; margin: 0px; background-color: transparent; }
  </style>
<body>
	<label>调用地址：</label><input style="width:500px" id="url" value="http://localhost:8080/voip/api/client/record/upload_record.json"/>
	<div class="clear"></div>
	<form id="form1" action="" target="form1" method="post">
		<fieldset>
			<legend>更新状态</legend>
			<label>CMD：</label><input type="text" name="cmd" value="channelstatus" readonly/><div class="hr"></div>
			<label>录音设备编号：</label><input type="text" name="satellite" value="00.00.00"/><br/>
			<label>状态：</label><br/>
			<textarea name="status">
{
 "diskSize":"100G",
 "diskSurplusSize":"90G",
 "diskUsagePercent":"10",
 "diskStatus":0,
 "channels":
    [{
        "ch":"1",
        "state":"2",
        "phone":"10000",
        "timelen":"60",
        "peer":"1",
        "serial":"1.2.3"
    }]
}</textarea>
			<div style="text-align:center"><a name="1" onclick="send(this)">提交</a></div>
		</fieldset>
	</form>
	<form id="form2" action="" target="form2" method="post" enctype="multipart/form-data" style="width:600px;margin-left:100px;">
		<fieldset>
			<legend>上传录音</legend>
			<label>CMD：</label><input type="text" name="cmd" value="upload" readonly/>
			<label>录音文件：</label><input type="file" name="file"/><div class="hr"></div>
			<label>设备编号：</label><input type="text" name="satellite" value="00:00:00"/>
			<label>序列号：</label><input type="text" name="user_id" value="1.2.3"/><div class="hr"></div>
			<label>开始时间：</label><input type="text" name="start_time_secs" id="start_time_secs"/>
			<label>挂断时间：</label><input type="text" name="start_time_hangup" id="start_time_hangup"/><div class="hr"></div>			
			<label>电话号码：</label><input type="text" name="callid_dialed" value="10000"/>
			<label>通话方向：</label><input type="text" name="direction" value="in"/><div class="hr"></div>
			<label>接通秒数：</label><input type="text" name="duration_secs" value="16"/>
			<label>是否录音：</label><input type="text" name="recorded" value="1"/><div class="hr"></div>
			<label>录音设备配置的RJ11口：</label><input type="text" name="channel" value="1"/><div class="hr"></div>
			<label>　　ID：</label><input type="text" name="record_id"/><div class="hr"></div>
			<div style="text-align:center"><a name="2" onclick="send(this)">提交</a></div>
		</fieldset>
	</form>
	<br>
	
	<div class="clear"></div>
	<div style="text-align:center">
	<label>URL：</label><input type="text" id="urlId" value="http://127.0.0.1:8082/"/>
	<label>MAC：</label><input type="text" id="devMac" value="0E:0F:30:4C:CF:48"/>
	<input type="button" id="getServiceData" value="获取数据"/></div>
	
	<iframe id="form1"></iframe>
	<iframe id="form2" style="margin-left:100px;"></iframe>
	<div class="clear"></div>
	
	<script type="text/javascript">
	(function(){
		var time=parseInt(new Date().getTime()/1000);
		document.getElementById('start_time_secs').value=time;
		document.getElementById('start_time_hangup').value=time+30;
		
		$("#callphone").click(function(){
			var phone = $("#phoneno").val();
			if(phone==null||phone.length<3){
				alert("号码不能为空");
			}
			var voip1 = new voipCall();
			voip1.CallPhoneByUser($("#urlId").val(),$("#userName").val(),$("#userPass").val(),phone,function(data){
				if(data.code==0){
					alert("拔号成功："+$("#phoneno").val());
				}else{
					alert("拔号失败："+$("#phoneno").val());
				}
			});
		});
		
		$("#getServiceData").click(function(){
			var url = $("#urlId").val()+"voip/api/client/xfrecord/upload_record.jsonp?callback=?&cmd=getMessageList"
				+"&satellite="+$("#devMac").val()+"&waterLine=0";
			//-本地有客户端拔号
			getJsonP(url,{},function(data){
				if(data.status==0){
					alert("成功：+"+JSON.stringify(data));
				}else{
					alert("失败");
				}
			});			
		});
	})();
	function send(e){
		var form=document.getElementById('form'+e.name);
		form.action=document.getElementById('url').value;
		form.submit();
	}
	</script>
</body>
</html>